package com.bigfreakindeals.Models;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;

import com.bigfreakindeals.Controller.ImageListener;

public class DrawableImageSlug implements ImageListener{
	
	public Drawable drawable_tabNormal;
	public Drawable drawable_tabSelected;
	public Drawable drawable_beansay_btn_selected;
	public Drawable drawable_beansay_btn_normal;
	public Drawable drawable_beansay_dog;
	public Drawable drawable_beansay_text;
	public Drawable drawable_beansay_nodeal;
	public Drawable drawable_beansay_dog_shadow;
	
	public Bitmap bitmap_drawable_tabNormal;
	public Bitmap bitmap_drawable_tabSelected;
	public Bitmap bitmap_drawable_beansay_btn_selected;
	public Bitmap bitmap_drawable_beansay_btn_normal;
	public Bitmap bitmap_drawable_beansay_dog;
	public Bitmap bitmap_drawable_beansay_text;
	public Bitmap bitmap_drawable_beansay_nodeal;
	public Bitmap bitmap_drawable_beansay_dog_shadow;
	
	public String slug;
	
	private final String String_drawable_tabNormal;
	private final String String_drawable_tabSelected;
	private final String String_drawable_beansay_btn_selected;
	private final String String_drawable_beansay_btn_normal;
	private final String String_drawable_beansay_dog;
	private final String String_drawable_beansay_text;
	private final String String_drawable_beansay_nodeal;
	private final String String_drawable_beansay_dog_shadow;
	
		public DrawableImageSlug(String slug){
			this.slug = slug;
			
			String_drawable_tabNormal =  (slug+".tab.rest.small.png").toLowerCase();
			String_drawable_tabSelected = (slug+".tab.push.small.png").toLowerCase();
			String_drawable_beansay_btn_selected = (slug+".beans.says.push.small.png").toLowerCase();
			String_drawable_beansay_btn_normal = (slug+".beans.says.rest.small.png").toLowerCase();
			String_drawable_beansay_dog = (slug+".dog.beans.says.png").toLowerCase();
			String_drawable_beansay_text = (slug+".TXT.beans.says.png").toLowerCase();
			String_drawable_beansay_nodeal = (slug+".nodeals.beans.png").toLowerCase();
			String_drawable_beansay_dog_shadow = (slug+".nodeals.beans.png").toLowerCase();
			
		}
		
		
				
		public void setdrawableImage(String filename1, Bitmap bitmap){
			
			String filename= filename1.toLowerCase();
			if (filename.contentEquals(String_drawable_beansay_btn_normal)){
				bitmap_drawable_beansay_btn_normal = bitmap;
				drawable_beansay_btn_normal = new BitmapDrawable(bitmap);
			}else if (filename.contentEquals( String_drawable_beansay_btn_selected)){
				bitmap_drawable_beansay_btn_selected= bitmap;
				drawable_beansay_btn_selected = new BitmapDrawable(bitmap);
			}else if (filename.contentEquals(String_drawable_beansay_dog)){
				bitmap_drawable_beansay_dog = bitmap;
				drawable_beansay_dog = new BitmapDrawable(bitmap);
			}else if (filename.contentEquals(String_drawable_beansay_dog_shadow)){
				bitmap_drawable_beansay_dog_shadow = bitmap;
				drawable_beansay_dog_shadow = new BitmapDrawable(bitmap);
			}else if (filename.contentEquals(String_drawable_beansay_nodeal)){
				bitmap_drawable_beansay_nodeal = bitmap;
				drawable_beansay_nodeal = new BitmapDrawable(bitmap);
			}else if (filename.contentEquals(String_drawable_beansay_text)){
				bitmap_drawable_beansay_text = bitmap;
				drawable_beansay_text = new BitmapDrawable(bitmap);
			}else if (filename.contentEquals(String_drawable_tabNormal)){
				bitmap_drawable_tabNormal = bitmap;
				drawable_tabNormal = new BitmapDrawable(bitmap);
			}else if (filename.contentEquals(String_drawable_tabSelected)){
				bitmap_drawable_tabSelected = bitmap;
				drawable_tabSelected = new BitmapDrawable(bitmap);
			}		
	
			
			if (bitmap_drawable_beansay_nodeal == null && bitmap_drawable_beansay_dog_shadow!=null){
				bitmap_drawable_beansay_nodeal = bitmap_drawable_beansay_dog_shadow;
				drawable_beansay_nodeal = new BitmapDrawable(bitmap_drawable_beansay_nodeal);
				
			}if (bitmap_drawable_beansay_dog_shadow == null && bitmap_drawable_beansay_nodeal!=null){
				bitmap_drawable_beansay_dog_shadow = bitmap_drawable_beansay_nodeal;
				drawable_beansay_dog_shadow = new BitmapDrawable(bitmap_drawable_beansay_dog_shadow);
				
			}
		}
		
		public ImageListener getListener() {
			return this;
		}


		@Override
		public void imageResponse(Bitmap bitmap, String filename/*filename*/, String universityId/*slug*/) {
			// TODO Auto-generated method stub
			if (universityId.equals(slug)){
				setdrawableImage(filename, bitmap);
			}
		}
		
		
}
